package igeomap.domain;

import java.io.File;

import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class CameraPreviewHolder implements SurfaceHolder.Callback {

	private SurfaceHolder mHolder;
	private Fotocamera hFotocamera;
	public CameraPreviewHolder(SurfaceView surfaceView)
	{
		mHolder=surfaceView.getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        hFotocamera=Fotocamera.getFotocameraIstance();
	}
	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub
		
		hFotocamera.StopPreview();
		hFotocamera.SetPreviewDisplay(mHolder);
		hFotocamera.StartPreview();
          
          
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) 
	{
		// TODO Auto-generated method stub
		hFotocamera.InizializzaCamera();
		hFotocamera.SetPreviewDisplay(mHolder);
		hFotocamera.StartPreview();
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder)
    {
		// TODO Auto-generated method stub
		hFotocamera.StopPreview();
		hFotocamera.RilasciaCamera();
	}
	public void TakePicture()
	{
		hFotocamera.takePicture();
	}
	
	
	
}
